/*
 * Copyright (c) 2025 Industrial Software Feature Database
 */
package com.comac.ins.isfd.constant.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 导入方式
 *
 * @author hxloongs
 * @date 2025-4-28
 */
@AllArgsConstructor
@Getter
public enum IsfdImportMethodEnum {
    JSON("Json导入"),
    API("API导入"),
    XML("XML导入"),
    SITE("页面新增"),
    EXCEL("EXCEL导入"),
    DIRECTLY("直接导入"),
    PARSED("结构化"),
    COMPRESSED("压缩包导入");
    private final String desc;

    public static boolean isValid(String value) {
        for (IsfdImportMethodEnum method : IsfdImportMethodEnum.values()) {
            if (method.getDesc().equalsIgnoreCase(value)) {
                return true;
            }
        }
        return false;
    }

    public static IsfdImportMethodEnum fromValue(String value) {
        for (IsfdImportMethodEnum method : IsfdImportMethodEnum.values()) {
            if (method.getDesc().equalsIgnoreCase(value)) {
                return method;
            }
        }
        return null;
    }

    public static boolean canDownload(String value) {
        if (JSON.getDesc().equalsIgnoreCase(value) || XML.getDesc().equalsIgnoreCase(value)
            || EXCEL.getDesc().equalsIgnoreCase(value) || COMPRESSED.getDesc().equalsIgnoreCase(value)) {
            return Boolean.TRUE;
        }
        return Boolean.FALSE;
    }
}
